package com.example.wanbaqian.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.example.wanbaqian.R;
import com.example.wanbaqian.bean.ActivityInfo;
import com.example.wanbaqian.utils.TimeUtils;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;

/**
 * Created by Administrator on 2017/4/6 0006.
 * 发现活动适配器
 */

public class FindActivityAdapter extends CommonAdapter<ActivityInfo> {
    public FindActivityAdapter(Context context, int layoutId, List<ActivityInfo> datas) {
        super(context, layoutId, datas);
    }

    @Override
    public void onViewHolderCreated(ViewHolder holder, View itemView) {
        super.onViewHolderCreated(holder, itemView);
        AutoUtils.autoSize(itemView);
    }

    @Override
    protected void convert(ViewHolder holder, ActivityInfo item, int position) {
        Glide.with(holder.itemView.getContext()).load(item.getThumbnail_url()).into((ImageView) holder.getView(R.id.iv_img));
        holder.setText(R.id.tv_title, item.getActivity_title());
        holder.setText(R.id.tv_time, TimeUtils.getStrTime(item.getPublish_time()+"",""));
    }
}
